package com.jds.test.bio.p8;

/**
 * https://www.cnblogs.com/silyvin/articles/12037918.html
 * Created by joyce on 2019/11/26.
 */


import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;


public class Client {

    public static final int PORT = 12123;
    public static final int BUFFER_SIZE = 1300;

    public static void main(String []f) throws IOException {
        new Client().client();
    }

    //客户端代码
    public void client() throws UnknownHostException, IOException{

        final String s1 = "49.235.75.155";// tx
        final String s2 = "localhost";
        final String s3 = "39.100.99.222";// al


    //    Socket s = new Socket(s1,PORT);//创建socket连接
        Socket s = new Socket();
        System.out.println(s.getReceiveBufferSize());
        System.out.println(s.getSendBufferSize());
        s.setReceiveBufferSize(100);

        // 这个100会先于滑动窗口导致拆包
    //    s.setSendBufferSize(100);
        s.setSendBufferSize(BUFFER_SIZE);
        s.connect(new InetSocketAddress(s1, PORT));

        // 发送一个介于对方window 1152，与mss 1460的之间大小的包
        s.getOutputStream().write(new byte[BUFFER_SIZE]);


    }
}